#include"Http.hpp"
void Login(Request &req, Response &resp)
{
    // req.Args();
    LOG(LogLevel::DEBUG) << req.Args() << ", 我们成功进入到了处理数据的逻辑";
    std::string text = "hello: " + req.Args(); // username=zhangsan&passwd=123456

    // 登录认证

    resp.SetCode(200);
    resp.SetHeaders("Content-Type","text/plain");
    resp.SetHeaders("Content-Length", std::to_string(text.size()));
    resp.SetText(text);
}
int main(int argc,char* argv[])
{
    if(argc!=2)
    {
        std::cout<<"Usage:"<<argv[0]<<"port"<<std::endl;
        return 0;
    }
    uint16_t port=std::stoi(argv[1]);
    
    ENABLE_CONSOLE_LOG_STRATEGY();
    //协议层
    std::unique_ptr<Http> tshp=std::make_unique<Http>(port);

    tshp->RegisterService("/login",Login);
    tshp->Start();
    return 0;
}